<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input :type="pw?'text':'password'" v-model="password" />
    <button @click="add">
      {{ pw?'密码消失':'密码显示'}}
    </button>
    </div>
</body>
<script src="Vue.js"></script>
<script>
    //7. 一个密码输入框，带有一个按钮用于切换显示或隐藏密码文本。  参考 https://www.jq22.com/yanshi374
    const {createApp,ref} =Vue;
    createApp({
        setup(){
            let password = ref('');
            let pw = ref(false);

        function add (){
          pw.value =!pw.value;
        };
          
        return{
            password,
            pw,
            add
           
        }
        }
        
    }).mount('#app')
</script>
</html>